<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
            <li>
			用户id：<input type="text" name="userId"/>
        </li>
	            <li>
			卡号：<input type="text" name="cardNo"/>
        </li>
	            <li>
			卡密：<input type="text" name="cardPwd"/>
        </li>
	            <li>
			面额：<input type="text" name="amount"/>
        </li>
	            <li>
			兑换批次：<input type="text" name="exNo"/>
        </li>
	    		<li class="select-time">
			<label>兑换时间： </label>
			<input type="text" class="date-input" id="startExTime" placeholder="开始" name="params[beginExTime]"/>
			<span>-</span>
			<input type="text" class="date-input" id="endExTime" placeholder="结束" name="params[endExTime]"/>
		</li>
	            <li>
			不否已使用(0否，1是)：<input type="text" name="useFlag"/>
        </li>
	            <li>
			删除标志（0代表存在 1代表删除）：<input type="text" name="delFlag"/>
        </li>
	            <li>
			创建者：<input type="text" name="createBy"/>
        </li>
	    		<li class="select-time">
			<label>创建时间： </label>
			<input type="text" class="date-input" id="startCreateTime" placeholder="开始" name="params[beginCreateTime]"/>
			<span>-</span>
			<input type="text" class="date-input" id="endCreateTime" placeholder="结束" name="params[endCreateTime]"/>
		</li>
	            <li>
			更新者：<input type="text" name="updateBy"/>
        </li>
	    		<li class="select-time">
			<label>更新时间： </label>
			<input type="text" class="date-input" id="startUpdateTime" placeholder="开始" name="params[beginUpdateTime]"/>
			<span>-</span>
			<input type="text" class="date-input" id="endUpdateTime" placeholder="结束" name="params[endUpdateTime]"/>
		</li>
	            <li>
			备注信息：<input type="text" name="remark"/>
        </li>
								<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<div class="col-sm-12 search-collapse">
				<div class="select-list">
					<ul id="countList">
					</ul>
				</div>
			</div>
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="system:wdyShoppingCard:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.editFull()" shiro:hasPermission="system:wdyShoppingCard:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:wdyShoppingCard:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="system:user:import">
					<i class="fa fa-upload"></i> 导入
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:wdyShoppingCard:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:wdyShoppingCard:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:wdyShoppingCard:remove')}]];
        var prefix = ctx + "system/wdyShoppingCard";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                importUrl: prefix + "/importData",
                importTemplateUrl: prefix + "/importTemplate",
                modalName: "购物卡",
		        showExport: false,
                sortName: "createTime",
                sortOrder: "desc",
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : 'id',
					visible: false
				},
				{
					field : 'extraData[mobile]',
					title : '用户手机号码',
					sortable: false,
					formatter: function (value, row, index) {
						return row.extraData['mobile'];
					}
				},
				{
					field : 'userId', 
					title : '用户id',
					sortable: true
				},
				{
					field : 'cardNo', 
					title : '卡号',
					sortable: true
				},
				{
					field : 'cardPwd', 
					title : '卡密',
					sortable: true
				},
				{
					field : 'amount', 
					title : '面额',
					sortable: true
				},
				{
					field : 'exNo', 
					title : '兑换批次',
					sortable: true
				},
				{
					field : 'exTime', 
					title : '兑换时间',
					sortable: true
				},
				{
					field : 'useFlag', 
					title : '不否已使用(0否，1是)',
					sortable: true
				},
				{
					field : 'delFlag', 
					title : '删除标志（0代表存在 1代表删除）',
					sortable: true
				},
				{
					field : 'createBy', 
					title : '创建者',
					sortable: true
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true
				},
				{
					field : 'updateBy', 
					title : '更新者',
					sortable: true
				},
				{
					field : 'updateTime', 
					title : '更新时间',
					sortable: true
				},
				{
					field : 'remark', 
					title : '备注信息',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.editFull(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
            getCount();
        });
        function getCount() {
            var config = {
                url: prefix + "/getCount",
                type: "get",
                dataType: "json",
                data: "",
                beforeSend: function () {
                },
                success: function(result) {
                    var str = "";
                    for(var i = 0; i < result.amountArray.length; i++) {
                        str += "<li>" + result.amountArray[i] + "面额:" + result.countList[i] + "张</li>"
					}
					$("#countList").html(str)
                }
            };
            $.ajax(config)
        }
    </script>
</body>
<form id="importForm" enctype="multipart/form-data" class="mt20 mb10" style="display: none;">
	<div class="col-xs-offset-1">
		<input type="file" id="file" name="file"/>
		<div class="mt10 pt5">
			<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
		</div>
		<font color="red" class="pull-left mt10">
			提示：仅允许导入“xls”或“xlsx”格式文件！
		</font>
	</div>
</form>
</html>